#!/bin/bash

export PATH=/bin:/sbin:/usr/bin
port=$(awk -F ' ' '/^Port/{print $2}' /etc/ssh/sshd_config)

if [ "$port" == '' ]
then
	exit 0
else
	/sbin/iptables -F
	iptables -P INPUT DROP
	iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
	iptables -A INPUT -p icmp --icmp-type any -j ACCEPT
	iptables -A INPUT -i lo -j ACCEPT
    
	iptables -A INPUT -p tcp --dport 80 -j ACCEPT
	iptables -A INPUT -p tcp --dport 443 -j ACCEPT
	iptables -A INPUT -p tcp --dport 10050:10052 -j ACCEPT
	iptables -A INPUT -p tcp --dport $port -j ACCEPT
	
fi

